package com.mycompany.servicemodule;

import java.util.Hashtable;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.util.tracker.ServiceTracker;

public class Activator implements BundleActivator {

	
	private ServiceRegistration registration; 
	CommonBusinessObjectService myBusinessObjectService;
	//static ServiceTracker businessServiceTracker;
	
	
	public void start(BundleContext context) throws Exception {
		
		//System.out.println("servicemodule.start");
		myBusinessObjectService = new CommonBusinessObjectImpl();
		
		// register the myBusinessObjectService
		registration = context.registerService(CommonBusinessObjectService.class.getName(), myBusinessObjectService, new Hashtable());
		//System.out.println("registered myBusinessObjectService");
		
		// create a tracker and track the myBusinessObjectService
		//businessServiceTracker = new ServiceTracker(context, CommonBusinessObjectService.class.getName(), null);
		//businessServiceTracker.open();
		
		// grab the myBusinessObjectService
		//myBusinessObjectService = (CommonBusinessObjectImpl) businessServiceTracker.getService();
		//myBusinessObjectService.speak();
		//myBusinessObjectService.yell();
	}
	
	public void stop(BundleContext context) throws Exception {
		// close the myBusinessObjectService tracker
		//businessServiceTracker.close();
		//businessServiceTracker = null;
		
		myBusinessObjectService = null;
	}

}
